<template>
    <div class="login-wrapper">
        <div class="custom-topHr"></div>

        <div class="logo-box">
            <img class="logo" src="@/assets/images/logo1.png">
        </div>
        <div class="login-box">
            <customForm :type="type"/>

            <div class="submit-box">
                <button class="submit-btn" @click="login">提 交</button>
                
                <!-- <a class="msg-login" href="#">短信验证登录</a> -->

                <p class="privacy-txt">
                    <span>登录即代表已经并同意</span>
                    <a href="#">《还美医疗整形隐私政策》</a>
                </p>
            </div>
        </div>
    </div>
</template>

<script type="text/ecmascript-6">
import customForm from "./form";
import constant from "@/utils/constant.js";
// 引用API文件
import http from "@/utils/http.js";

export default {
  name: "register_store",
  data() {
    return {
      type: "registerStore"
    };
  },
  components: {
    customForm
  },
  methods: {
    login() {
      let username = this.$store.state.loginform.mobile;
      let password = this.$store.state.loginform.password;

      if (username == "" || password == "") {
        this.$message({
          message: '请填写用户名或密码',
          type: 'warning'
        });
      } else {
        http.post(this, {
          url: "passport/login",
          data: {
            username: username,
            password: password
          },
          dataType: "json",
          success: function(data) {
            console.log("登录:", data);
            if (data.status == 1) {
              let user_info = data.info;
              localStorage.setItem("user_name", user_info.username);
              localStorage.setItem("user_token", user_info.token);
              this.$router.push({
                //核心语句
                path: "/center"
              });
            } else {
              this.$message.error(data.info);
            }
          }
        });
      }
    }
  }
};
</script>

<style scoped lang="scss">
</style>
